Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

247
Visualizações
React JS | Firebase | reCAPTCHA already rendered issue

I have a component like this -->

<form onSubmit={verifyOTP}>
            ....
            .....
           <div className="auth-btn-wrap">
           <button disabled={isLoading ? true : false} type="submit" className="btn btrimary">
           {isLoading ? (<CircularProgress />) : (<>Verify OTP</>)}</button>
           {isLoading ? null : (<Link onClick={resendOTP}>Resend</Link>)}
        </div>
     <div id="recaptcha-container" />
</form>

verifyOTP function looks like this -->

const verifyOTP = (e: React.SyntheticEvent) => {
    e.preventDefault();
    if (window.confirmationResult) {
      window.confirmationResult
        .confirm(otp)
        .then(async () => {
          dispatch(signupStartStart({ user: { ...user, otp, otpConfirm: window.confirmationResult }, history }));
        })
        .catch((e: any) => {
          console.error(e);
          snack.error("Invalid OTP");
        });
    } else {
      window.location.reload();
    }
  };

In my user saga file, action signupStartStart looks like this -->

{.......
    .......
            const result = yield call(sendOTPWithFb, {
              phoneNumber: user.countryCode + user.phoneNumber, containerName: "recaptcha-container"
            });

            yield put (setLoading ({loading: false}));

            if (result) {
              yield put(showVerifyOTPSuccess());
              snack.success('An OTP has been sent to you mobile');
            } else {
              snack.error("Unable to send OTP");
            }
        }

The function that sends OTP is this -->

export const sendOTPWithFb = async (data: any): Promise<boolean> => {
  const { phoneNumber, containerName } = data

  try {
    const appVerifier = new FirebaseTypes.auth.RecaptchaVerifier(
      containerName,
      {
        size: "invisible",
      }
    );

    const confirmationResult = await firebase
      .auth()
      .signInWithPhoneNumber(`${phoneNumber}`, appVerifier);
    window.confirmationResult = confirmationResult;
    return true;
  } catch (error) {
    console.error(error);
    return false;
  }
};

Whenever I click on Resend OTP button, it gives me error that ---> "reCAPTCHA has already been rendered in this element"

PLease let me know how to resolve this issue

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda